package cn.com.code.design;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 模拟储蓄卡功能
 *
 * @author zhengpei
 * @date 2021/9/8
 */
public class CashCard extends BankCard {

  private Logger logger = LoggerFactory.getLogger(CashCard.class);

  public CashCard(String cardNo, LocalDateTime cardDate) {
    super(cardNo, cardDate);
  }

  /**
   * 规则过滤,储蓄卡直接默认通过
   *
   * @return
   */
  @Override
  boolean rule() {
    return false;
  }

  /**
   * 提线
   *
   * @param orderId
   * @param amount
   * @return
   */
  public String withdraw(String orderId, BigDecimal amount) {
    logger.info("提现成功,订单号:[{}],金额:[{}]", orderId, amount);
    return super.negative(orderId, amount);
  }

  /**
   * 储存
   * @param orderId
   * @param amount
   * @return
   */
  public String recharge(String orderId, BigDecimal amount) {
    logger.info("储存成功,订单号:[{}],金额:[{}]", orderId, amount);
    return super.positive(orderId,amount);
  }

  /**
   * 风险校验
   *
   * @param cardNo  卡号
   * @param orderId 单号
   * @param amount  金额
   * @return 状态
   */
  public boolean checkRisk(String cardNo, String orderId, BigDecimal amount) {
    // 模拟风控校验
    logger.info("风控校验，卡号：{} 单号：{} 金额：{}", cardNo, orderId, amount);
    return true;
  }

}
